<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>OpenFOAM 中的热物理类之 hashTable 的创建 | Giskard&#39;s CFD Learning Tricks</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="这一篇来看一下热物理类是如何编译并创建储存了可选模型的 hashTable 的。">
<meta property="og:type" content="article">
<meta property="og:title" content="OpenFOAM 中的热物理类之 hashTable 的创建">
<meta property="og:url" content="http://xiaopingqiu.github.io/2016/06/25/thermophysics2/index.html">
<meta property="og:site_name" content="Giskard's CFD Learning Tricks">
<meta property="og:description" content="这一篇来看一下热物理类是如何编译并创建储存了可选模型的 hashTable 的。">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="OpenFOAM 中的热物理类之 hashTable 的创建">
<meta name="twitter:description" content="这一篇来看一下热物理类是如何编译并创建储存了可选模型的 hashTable 的。">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">
  
<!-- Google Analytics -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

##ga('create', '[object Object]', 'auto');
ga('create', 'UA-62501686-1', 'auto');
ga('send', 'pageview');

</script>
<!-- End Google Analytics -->


</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Giskard&#39;s CFD Learning Tricks</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">CFD and Scientific Computing</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
          <a class="main-nav-link" href="/atom.xml">Rss</a>
        
          <a class="main-nav-link" href="/about">About</a>
        
      </nav>
      <nav id="sub-nav">
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="q" value="site:http://xiaopingqiu.github.io"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main"><article id="post-thermophysics2" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/06/25/thermophysics2/" class="article-date">
  <time datetime="2016-06-25T06:46:48.000Z" itemprop="datePublished">2016-06-25</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/OpenFOAM/">OpenFOAM</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      OpenFOAM 中的热物理类之 hashTable 的创建
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>这一篇来看一下热物理类是如何编译并创建储存了可选模型的 hashTable 的。</p>
<a id="more"></a>
<p>根据以前的经验，编译和构建 hashTable 肯定是跟这个源文件有关：<code>src/thermophysicalModels/basic/rhoThermo/rhoThermos</code>。<br>这个文件里，全部都是在调用宏函数。而且，从宏函数的参数来看，似乎就是个排列组合的游戏，把所有可用的组合都写了一遍。<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">makeThermo</span><br><span class="line">(</span><br><span class="line">    rhoThermo,</span><br><span class="line">    heRhoThermo,</span><br><span class="line">    pureMixture,</span><br><span class="line">    constTransport,</span><br><span class="line">    sensibleInternalEnergy,</span><br><span class="line">    hConstThermo,</span><br><span class="line">    perfectGas,</span><br><span class="line">    specie</span><br><span class="line">);</span><br><span class="line">......</span><br></pre></td></tr></table></figure></p>
<p>为了弄清这部分内容，需要先理解 <code>makeThermo</code> 这个宏函数的定义，见 <code>src/thermophysicalModels/basic/fluidThermo/makeThermo.H</code>：<br><figure class="highlight livescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#define makeThermoTypedefs(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">typedef                                                                       <span class="string">\</span></span><br><span class="line">    Transport                                                                 <span class="string">\</span></span><br><span class="line">    &lt;                                                                         <span class="string">\</span></span><br><span class="line">        <span class="attribute">species</span>::thermo                                                       <span class="string">\</span></span><br><span class="line">        &lt;                                                                     <span class="string">\</span></span><br><span class="line">            Thermo                                                            <span class="string">\</span></span><br><span class="line">            &lt;                                                                 <span class="string">\</span></span><br><span class="line">                EqnOfState                                                    <span class="string">\</span></span><br><span class="line">                &lt;                                                             <span class="string">\</span></span><br><span class="line">                    Specie                                                    <span class="string">\</span></span><br><span class="line">                &gt;                                                             <span class="string">\</span></span><br><span class="line">            &gt;,                                                                <span class="string">\</span></span><br><span class="line">            Type                                                              <span class="string">\</span></span><br><span class="line">        &gt;                                                                     <span class="string">\</span></span><br><span class="line">    &gt; Transport<span class="comment">##Type##Thermo##EqnOfState##Specie;                            \</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">typedef                                                                       <span class="string">\</span></span><br><span class="line">    Cthermo                                                                   <span class="string">\</span></span><br><span class="line">    &lt;                                                                         <span class="string">\</span></span><br><span class="line">        BaseThermo,                                                           <span class="string">\</span></span><br><span class="line">        Mixture&lt;Transport<span class="comment">##Type##Thermo##EqnOfState##Specie&gt;                  \</span></span><br><span class="line">    &gt; Cthermo<span class="comment">##Mixture##Transport##Type##Thermo##EqnOfState##Specie;          \</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">defineTemplateTypeNameAndDebugWithName                                        <span class="string">\</span></span><br><span class="line">(                                                                             <span class="string">\</span></span><br><span class="line">    Cthermo<span class="comment">##Mixture##Transport##Type##Thermo##EqnOfState##Specie,            \</span></span><br><span class="line">    (                                                                         <span class="string">\</span></span><br><span class="line">        <span class="comment">#Cthermo"&lt;"#Mixture"&lt;"                                                \</span></span><br><span class="line">      + Transport<span class="comment">##Type##Thermo##EqnOfState##Specie::typeName()               \</span></span><br><span class="line">      + <span class="string">"&gt;&gt;"</span>                                                                  <span class="string">\</span></span><br><span class="line">    ).c_str(),                                                                <span class="string">\</span></span><br><span class="line">    <span class="number">0</span>                                                                         <span class="string">\</span></span><br><span class="line">);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#define makeThermo(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">makeThermoTypedefs                                                            <span class="string">\</span></span><br><span class="line">(                                                                             <span class="string">\</span></span><br><span class="line">    BaseThermo,                                                               <span class="string">\</span></span><br><span class="line">    Cthermo,                                                                  <span class="string">\</span></span><br><span class="line">    Mixture,                                                                  <span class="string">\</span></span><br><span class="line">    Transport,                                                                <span class="string">\</span></span><br><span class="line">    Type,                                                                     <span class="string">\</span></span><br><span class="line">    Thermo,                                                                   <span class="string">\</span></span><br><span class="line">    EqnOfState,                                                               <span class="string">\</span></span><br><span class="line">    Specie                                                                    <span class="string">\</span></span><br><span class="line">)                                                                             <span class="string">\</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">addToRunTimeSelectionTable                                                    <span class="string">\</span></span><br><span class="line">(                                                                             <span class="string">\</span></span><br><span class="line">    basicThermo,                                                              <span class="string">\</span></span><br><span class="line">    Cthermo<span class="comment">##Mixture##Transport##Type##Thermo##EqnOfState##Specie,            \</span></span><br><span class="line">    fvMesh                                                                    <span class="string">\</span></span><br><span class="line">);                                                                            <span class="string">\</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">addToRunTimeSelectionTable                                                    <span class="string">\</span></span><br><span class="line">(                                                                             <span class="string">\</span></span><br><span class="line">    fluidThermo,                                                              <span class="string">\</span></span><br><span class="line">    Cthermo<span class="comment">##Mixture##Transport##Type##Thermo##EqnOfState##Specie,            \</span></span><br><span class="line">    fvMesh                                                                    <span class="string">\</span></span><br><span class="line">);                                                                            <span class="string">\</span></span><br><span class="line">                                                                              <span class="string">\</span></span><br><span class="line">addToRunTimeSelectionTable                                                    <span class="string">\</span></span><br><span class="line">(                                                                             <span class="string">\</span></span><br><span class="line">    BaseThermo,                                                               <span class="string">\</span></span><br><span class="line">    Cthermo<span class="comment">##Mixture##Transport##Type##Thermo##EqnOfState##Specie,            \</span></span><br><span class="line">    fvMesh                                                                    <span class="string">\</span></span><br><span class="line">);</span><br></pre></td></tr></table></figure></p>
<p>可见，在 <code>makeThermo</code> 这个宏函数里，先调用了 <code>makeThermoTypedefs</code> 宏函数，然后调用 <code>addToRunTimeSelectionTable</code> 函数。按照之前对 RTS 机制的理解，调用 <code>addToRunTimeSelectionTable</code> 函数的作用是往 hashTable 里插入元素，细节不需再赘述。这里主要来看看 <code>makeThermoTypedefs</code> 函数的功能，以上文列举的这个实例为例。先来看第一个 typedef：将实例中的参数代入后，<br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">typedef                                                                                       \</span><br><span class="line">    constTransport&lt;<span class="symbol">species:</span><span class="symbol">:thermo&lt;hConstThermo&lt;perfectGas&lt;specie&gt;&gt;</span>,sensibleInternalEnergy<span class="prompt">&gt;&gt;  </span>\</span><br><span class="line">    constTransportsensibleEnthalpyhConstThermoperfectGasspecie;</span><br></pre></td></tr></table></figure></p>
<p>第二个 typedef<br><figure class="highlight livescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">typedef                                                                                          <span class="string">\</span></span><br><span class="line">    heRhoThermo                                                                                  <span class="string">\</span></span><br><span class="line">    &lt;                                                                                            <span class="string">\</span></span><br><span class="line">        rhoThermo,                                                                               <span class="string">\</span></span><br><span class="line">        pureMixture&lt;constTransportsensibleEnthalpyhConstThermoperfectGasspecie&gt;                  <span class="string">\</span></span><br><span class="line">    &gt; heRhoThermopureMixtureconstTransportsensibleEnthalpyhConstThermoperfectGasspecie;</span><br></pre></td></tr></table></figure></p>
<p>除了这两个 typedef，还调用了 <code>defineTemplateTypeNameAndDebugWithName</code> 宏函数，这个函数的定义在 <code>src/OpenFOAM/db/typeInfo/className.H</code>：</p>
<figure class="highlight fortran"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">#define defineTemplateTypeNameAndDebugWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>, DebugSwitch)       \</span><br><span class="line">    defineTemplateTypeNameWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>);                               \</span><br><span class="line">    defineTemplateDebugSwitchWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>, DebugSwitch)</span><br><span class="line"></span><br><span class="line">#define defineTemplateTypeNameWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>)                           \</span><br><span class="line">    defineTypeNameWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>)</span><br><span class="line"></span><br><span class="line">#define defineTypeNameWithName(<span class="keyword">Type</span>, <span class="keyword">Name</span>)                                    \</span><br><span class="line">    const ::Foam::word <span class="keyword">Type</span>::typeName(<span class="keyword">Name</span>)</span><br></pre></td></tr></table></figure>
<p>很显然，这个宏函数的作用是修改类对应的 <code>typeName</code> 和 debug 选项。在 OpenFOAM 中，很多类中都会调用 <code>TypeName(&quot;typename&quot;)</code>，这里的 <code>TypeName</code> 也是一个宏函数，定义在 <code>src/OpenFOAM/db/typeInfo/className.H</code>:</p>
<figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="preprocessor">#define TypeName(TypeNameString)                                              \</span></span><br><span class="line">    ClassName(TypeNameString);                                                \</span><br><span class="line">    virtual <span class="keyword">const</span> word&amp; type() <span class="keyword">const</span> &#123; <span class="keyword">return</span> typeName; &#125;</span><br><span class="line"></span><br><span class="line"><span class="preprocessor">#define ClassName(TypeNameString)                                             \</span></span><br><span class="line">    ClassNameNoDebug(TypeNameString);                                         \</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">int</span> debug</span><br><span class="line">    </span><br><span class="line"><span class="preprocessor">#define ClassNameNoDebug(TypeNameString)                                      \</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span>* typeName_() &#123; <span class="keyword">return</span> TypeNameString; &#125;                 \</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">const</span> ::Foam::word typeName</span><br></pre></td></tr></table></figure>
<p>可见， <code>TypeName</code> 这个宏函数，声明了一个类静态变量 <code>typeName</code>，定义了一个函数 <code>type</code> 用于返回 <code>typeName</code> 的值，并定义了一个静态变量 <code>debug</code> 用于存储 debug 选项。这里与 RTS 机制有关的是 <code>typeName</code> 这个变量。</p>
<p>绕了半圈，回到 <code>defineTemplateTypeNameAndDebugWithName</code> 函数。了解了 <code>typeName</code> 这个变量的定义，很容易就能看出来， <code>defineTemplateTypeNameAndDebugWithName</code> 这个函数其实就是在对类的静态变量 <code>typeName</code> 进行赋值。根据上文的实例提供的参数，宏函数 <code>defineTemplateTypeNameAndDebugWithName</code> 可以理解为：对 <code>heRhoThermopureMixtureconstTransportsensibleEnthalpyhConstThermoperfectGasspecie</code> 对应的类的静态变量 <code>typeName</code> 进行赋值，赋值结果为：<br><code>heRhoThermo&lt;pureMixture&lt; + constTransport&lt;species::thermo&lt;hConstThermo&lt;perfectGas&lt;specie&gt;&gt;,sensibleInternalEnergy&gt;&gt;::typeName() + &gt;&gt;</code><br>。这里调用了 <code>constTransport</code> 类的成员函数 <code>typeName()</code>。<br>经过一番冗长的函数调用，得到的最终结果是：将 <code>heRhoThermopureMixtureconstTransportsensibleEnthalpyhConstThermoperfectGasspecie</code> 对应的类的静态变量 <code>typeName</code> 赋值为：<code>heRhoThermo&lt;pureMixture&lt;const&lt;hConst&lt;perfectGas&lt;specie&gt;&gt;,sensiblesensibleEnthalpy&gt;&gt;&gt;</code>。</p>
<p>至此，经过一番宏函数的调用，得到了 <code>addToRunTimeSelectionTable</code> 宏函数的参数。前面 RTS 机制部分讲过，这个函数的作用就是对 hashTable 增加元素，以</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">addToRunTimeSelectionTable</span>                                                    \</span><br><span class="line">(                                                                             \</span><br><span class="line">    <span class="tag">BaseThermo</span>,                                                               \</span><br><span class="line">    <span class="tag">Cthermo</span>#<span class="id">#Mixture</span>#<span class="id">#Transport</span>#<span class="id">#Type</span>#<span class="id">#Thermo</span>#<span class="id">#EqnOfState</span>#<span class="id">#Specie</span>,            \</span><br><span class="line">    <span class="tag">fvMesh</span>                                                                    \</span><br><span class="line">);</span><br></pre></td></tr></table></figure>
<p>为例，第一个参数，表示元素将增加到 <code>BaseThermo</code> 类（这里是 <code>rhoThermo</code> ）中声明的 hashTable，第二个参数，表示将要添加的类，添加成功以后，这个类的 <code>typeName</code> 将是 hashTable 的 key，而返回这个类的对象的一个函数，将是 hashTable 的 value。第三个参数对应着 hashTable 对象的名字，fvMesh 对应的 hashTable 对象名为 <code>fvMeshConstructorTable</code>，这与在 <code>rhoThermo</code> 中声明的名字是对应的。</p>
<p>最后总结如下：<br>宏函数</p>
<figure class="highlight lisp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">makeThermo</span><br><span class="line"><span class="list">(</span><br><span class="line">    <span class="keyword">rhoThermo</span>,</span><br><span class="line">    heRhoThermo,</span><br><span class="line">    pureMixture,</span><br><span class="line">    constTransport,</span><br><span class="line">    sensibleInternalEnergy,</span><br><span class="line">    hConstThermo,</span><br><span class="line">    perfectGas,</span><br><span class="line">    specie</span><br><span class="line">)</span><span class="comment">;</span></span><br></pre></td></tr></table></figure>
<p>调用以后，向 <code>rhoThermo</code> 类中声明的 hashTable 中增加了一组元素，其 key 为 <code>heRhoThermo&lt;pureMixture&lt;const&lt;hConst&lt;perfectGas&lt;specie&gt;&gt;,sensibleInternalEnergy&gt;&gt;&gt;</code> ，value 对应的函数返回的是类</p>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">heRhoThermo                                                                 </span><br><span class="line">&lt;                                                                        </span><br><span class="line">    rhoThermo,                                                          </span><br><span class="line">    pureMixture</span><br><span class="line">    &lt;</span><br><span class="line">        constTransport&lt;<span class="symbol">species:</span><span class="symbol">:thermo&lt;hConstThermo&lt;perfectGas&lt;specie&gt;&gt;</span>,sensibleInternalEnergy<span class="prompt">&gt;&gt;</span><br><span class="line">    </span>&gt;                 </span><br><span class="line">&gt;</span><br></pre></td></tr></table></figure>
<p>的对象。</p>
<p>每调用一次 <code>makeThermo</code> 函数，就增加了一个新组元素，也即增加了一个可选的模型。不同的参数，其实对应的是不同的模板实例。</p>
<p>至此，就知道了在 <code>twoPhaseEulerFoam</code> 的 <code>phaseModel</code> 中定义的热物理类接口 <code>thermo_</code> 最终指向的是 <code>heRhoThermo</code> 类的对象。虽然代入的模板数很复杂，但整个架构仍然是基于 RTS 机制的。</p>
<p>接下来，要想理解能量方程，理解温度，粘度，压力等这些热物理相关的量是怎么计算更新的，就需要仔细看一下 <code>heRhoThermo</code> 类的继承派生关系了。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://xiaopingqiu.github.io/2016/06/25/thermophysics2/" data-id="cj2lay31t001pkkmblwbw87md" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Code-Explained/">Code Explained</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/thermophysicalModels/">thermophysicalModels</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/06/25/thermophysics3/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          OpenFOAM 中的热物理类之继承派生关系
        
      </div>
    </a>
  
  
    <a href="/2016/06/25/thermophysics1/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">OpenFOAM 中的热物理类之接口</div>
    </a>
  
</nav>

  
</article>


<section id="comments">
  <!-- 多说评论框 start -->
  <div class="ds-thread" data-thread-key="post-thermophysics2" data-title="OpenFOAM 中的热物理类之 hashTable 的创建" data-url="http://xiaopingqiu.github.io/2016/06/25/thermophysics2/"></div>
  <!-- 多说评论框 end -->
  <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
  <script type="text/javascript">
  var duoshuoQuery = {short_name:"xiaopingqiu"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
  <!-- 多说公共JS代码 end -->
</section>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/C/">C++</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/DEM/">DEM</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/OpenFOAM/">OpenFOAM</a><span class="category-list-count">44</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Paraview/">Paraview</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/swak4Foam/">swak4Foam</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/test/">test</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/vim/">vim</a><span class="category-list-count">1</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Boundary-conditions/">Boundary conditions</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/">C++</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CentOS/">CentOS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Code-Explained/">Code Explained</a><span class="tag-list-count">29</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/LES/">LES</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/LIGGGHTS/">LIGGGHTS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ODE/">ODE</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/OpenFOAM/">OpenFOAM</a><span class="tag-list-count">20</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Postprocessing/">Postprocessing</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Preprocessing/">Preprocessing</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/RTS/">RTS</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TIL/">TIL</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Windows/">Windows</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fvOptions/">fvOptions</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/groovyBC/">groovyBC</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/paraview/">paraview</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/thermophysicalModels/">thermophysicalModels</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/turbulence-model/">turbulence model</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wall-functions/">wall functions</a><span class="tag-list-count">4</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Boundary-conditions/" style="font-size: 15.56px;">Boundary conditions</a><a href="/tags/C/" style="font-size: 11.11px;">C++</a><a href="/tags/CentOS/" style="font-size: 10px;">CentOS</a><a href="/tags/Code-Explained/" style="font-size: 20px;">Code Explained</a><a href="/tags/LES/" style="font-size: 10px;">LES</a><a href="/tags/LIGGGHTS/" style="font-size: 10px;">LIGGGHTS</a><a href="/tags/ODE/" style="font-size: 10px;">ODE</a><a href="/tags/OpenFOAM/" style="font-size: 18.89px;">OpenFOAM</a><a href="/tags/Postprocessing/" style="font-size: 17.78px;">Postprocessing</a><a href="/tags/Preprocessing/" style="font-size: 11.11px;">Preprocessing</a><a href="/tags/RTS/" style="font-size: 12.22px;">RTS</a><a href="/tags/TIL/" style="font-size: 10px;">TIL</a><a href="/tags/Windows/" style="font-size: 10px;">Windows</a><a href="/tags/fvOptions/" style="font-size: 11.11px;">fvOptions</a><a href="/tags/groovyBC/" style="font-size: 10px;">groovyBC</a><a href="/tags/paraview/" style="font-size: 10px;">paraview</a><a href="/tags/test/" style="font-size: 11.11px;">test</a><a href="/tags/thermophysicalModels/" style="font-size: 14.44px;">thermophysicalModels</a><a href="/tags/turbulence-model/" style="font-size: 16.67px;">turbulence model</a><a href="/tags/vim/" style="font-size: 10px;">vim</a><a href="/tags/wall-functions/" style="font-size: 13.33px;">wall functions</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/">五月 2016</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">四月 2016</a><span class="archive-list-count">12</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">三月 2016</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">十二月 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">十一月 2015</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">十月 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">九月 2015</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">八月 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">六月 2015</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">五月 2015</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/04/">四月 2015</a><span class="archive-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2017/05/12/duoshuoAnnouncement/">多说评论系统将停止提供服务</a>
          </li>
        
          <li>
            <a href="/2016/08/27/ParaviewScritps/">Paraview 脚本一例</a>
          </li>
        
          <li>
            <a href="/2016/08/27/ParaviewCamera/">Paraview 中有关 Camera 的操作两例</a>
          </li>
        
          <li>
            <a href="/2016/08/27/ParaviewCustomFilter/">Paraview 中创建 Custom Filter</a>
          </li>
        
          <li>
            <a href="/2016/08/27/ParaviewStreamLineOnSlice/">在 Paraview 中画截面上的流线</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2017 Giskard Q.<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

<script src="//dn-lbstatics.qbox.me/lbservice/busuanzi/2.0/busuanzi.mini.js"/></script>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/atom.xml" class="mobile-nav-link">Rss</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
  <script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>


<script src="/js/script.js" type="text/javascript"></script>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-62501686-1', 'auto');
  ga('send', 'pageview');

</script>

  </div>
<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</body>
</html>